package com.wps.wdztv6.controller;

import com.wps.wdztv6.service.UserInfoService;
import com.wps.wdztv6.utils.AvatarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserInfoService userInfoService;

    @RequestMapping("/{id}")
    public void avatar(@PathVariable("id") String id, HttpServletResponse response) throws IOException {
        response.setContentType(MediaType.IMAGE_PNG_VALUE);
        userInfoService.outputUserAvatar(id, response.getOutputStream());
    }
}
